import urlConfig from './config.js'

const request = {}

request.globalRequest = (url, method, data, is_login = true) => {
	const headers = {
		'Content-Type': "application/json;charset=UTF-8",
		"Accept": "application/json,text/plain,*/*",
	}
	if (is_login) headers["Authorization"] = uni.getStorageSync("user_token");
	return uni.request({
		url: urlConfig + url,
		method: method,
		data: data,
		dataType: 'json',
		header: headers
	}).then(res => {
		return res[1]
		let statusCode = res.statusCode;
		if (statusCode != 200) {
			uni.showToast({
				title: res.data.msg
			})
		}
	}).catch(parmas => {})
}

export default request
